#ifndef __TEXTURE_H__
#define __TEXTURE_H__

#pragma once

#include "HardwareBuffer.h"

namespace Nezha
{
	// texture format
	enum TexFormat
	{
		TF_NONE,
		TF_R5G6B5,
		TF_A1R5G5B5,
		TF_A4R4G4B4,
		TF_A8,
		TF_L8,
		TF_A8L8,
		TF_R8G8B8,
		TF_A8R8G8B8,
		TF_A8B8G8R8,
		TF_L16,
		TF_G16R16,
		TF_A16B16G16R16,

		// 16-bit floating-point formats
		TF_R16F,
		TF_G16R16F,
		TF_A16B16G16R16F,

		// 32-bit floating-point formats
		TF_R32F,
		TF_G32R32F,
		TF_A32B32G32R32F,

		// DXT compressed formats.
		TF_DXT1,
		TF_DXT3,
		TF_DXT5,

		// Depth-stencil format.
		TF_D24S8,


		TF_NUM
	};

	// texture type
	enum TexType
	{
		TT_1D,
		TT_2D,
		TT_3D,
		TT_CUDE,

		TT_NUM
	};

	/** basic class fo texure. */
	class GRAPHICS_ENTRY Texture : public HardwareBuffer
	{
	public:
		virtual ~Texture(){}

		TexFormat getFormat() const;

		virtual TexType getType() const = 0;

		bool isCompressed() const;
		bool hasMipmaps() const;
		u16 getWidth() const;
		u16 getHeight() const;
		u16 getDepth() const;

NEZHA_INTERNAL:
		//virtual void _generateMipmaps() = 0;

		Texture(HardwareBuffer::Usage usage, TexFormat tf, u16 w, u16 h, u16 depth, bool hasMipmap, bool isCompressed)
			:HardwareBuffer(usage, false)
			,mFormat(tf)
			,mWidth(w)
			,mHeight(h)
			,mDepth(depth)
			,mHasMipmaps(hasMipmap)
			,mCompressed(isCompressed)
		{
		}
	protected:
		bool mHasMipmaps;
		bool mCompressed;
		TexFormat mFormat;

		u16 mWidth;
		u16 mHeight;
		u16 mDepth;
	};

	inline TexFormat Texture::getFormat() const
	{
		return mFormat;
	}

	inline bool Texture::isCompressed() const
	{
		return mCompressed;
	}

	inline bool Texture::hasMipmaps() const
	{
		return mHasMipmaps;
	}

	inline u16 Texture::getWidth() const
	{
		return mWidth;
	}

	inline u16 Texture::getHeight() const
	{
		return mHeight;
	}

	inline u16 Texture::getDepth() const
	{
		return mDepth;
	}

	typedef RefCountedPtr<Texture>::Default TexturePtr;

}//end namespace Nezha

#endif //end __TEXTURE_H__